Este documento presenta varios gráficos estadísticos de los datos de COVID-19 en Costa Rica publicados por el Ministerio de Salud en https://geovision.uned.ac.cr/oges/
library("ggplot2")
library("dplyr")
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library("DT")
library("readr")
library("plotly")
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
covid <- read.csv(file = "05_24_22_CSV_GENERAL.csv", sep = ";")
covid_nacional <-
read_delim(
file = "C:/Users/Universidad/analisis-covid-intermedio/05_24_22_CSV_GENERAL.csv",
delim = ";",
col_select = c("FECHA", "positivos", "fallecidos", "RECUPERADOS", "activos")
)
## Rows: 810 Columns: 5
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ";"
## chr (1): FECHA
## dbl (4): positivos, fallecidos, RECUPERADOS, activos
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
covid_cantonal_positivos <-
read_delim(
file = "C:/Users/Universidad/analisis-covid-intermedio/05_24_22_CSV_POSITIVOS.csv",
delim = ";",
locale = locale(encoding = "WINDOWS-1252"), # esto es para resolver el problema con las tildes
col_select = c("canton", "24/05/2022")
)
## Rows: 84 Columns: 2
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ";"
## chr (1): canton
## dbl (1): 24/05/2022
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
covid_cantonal_positivos <-
covid_cantonal_positivos %>%
rename(positivos = '24/05/2022')
covid_nacional <-
covid_nacional %>%
select(fecha = FECHA,
positivos,
fallecidos,
recuperados = RECUPERADOS,
activos) %>%
mutate(fecha = as.Date(fecha, format = "%d/%m/%Y"))
covid_nacional %>%
datatable(options = list(
pageLength = 5,
language = list(url = '//cdn.datatables.net/plug-ins/1.10.11/i18n/Spanish.json')
))
ggplot2_covid_nacional_linea <-
covid_nacional %>%
ggplot(aes(x = fecha, y = value, color = variable)) +
ggtitle("Casos acumulados de covid-19 en Costa Rica") +
xlab("Fecha") +
ylab("Casos") +
geom_line(aes(y = positivos, color = "Positivos")) +
geom_line(aes(y = recuperados, color = "Recuperados")) +
geom_line(aes(y = activos, color = "Activos")) +
geom_line(aes(y = fallecidos, color = "Fallecidos")) +
scale_colour_manual(
"",
values = c(
"Positivos" = "blue",
"Recuperados" = "green",
"Activos" = "red",
"Fallecidos" = "black"
)
)
ggplotly(ggplot2_covid_nacional_linea) %>% config(locale = 'es')
covid_cantonal_positivos %>%
datatable(options = list(
pageLength = 5,
language = list(url = '//cdn.datatables.net/plug-ins/1.10.11/i18n/Spanish.json')
))
ggplot2_covid_cantonal_barras <-
ggplot(data = covid_cantonal_positivos, aes(x = canton, y = positivos)) +
geom_bar(width = 0.5,
stat = "identity",
position = "dodge") +
ggtitle("Casos positivos por canton de COVID-19 en Costa Rica") +
xlab("Cantones") +
ylab("Positivos") +
theme(axis.text.x = element_text(angle = 90, size = 6.5))
ggplotly(ggplot2_covid_cantonal_barras) %>% config(locale = 'es')
ggplot2_covid_cantonal_barras <-
ggplot(data = covid_cantonal_positivos, aes(x = canton, y = positivos, fill = canton)) +
geom_bar(width = 0.5,
stat = "identity",
position = "dodge") +
ggtitle("Casos positivos por canton de COVID-19 en Costa Rica") +
xlab("Cantones") +
ylab("Positivos") +
theme(axis.text.x = element_text(angle = 90, size = 5))
ggplotly(ggplot2_covid_cantonal_barras) %>% config(locale = 'es')